package com.scuec.groupfive.service.impl;

import com.scuec.groupfive.entity.Post;
import com.scuec.groupfive.entity.PostComment;
import com.scuec.groupfive.entity.UserInfo;
import com.scuec.groupfive.mapper.PostMapper;
import com.scuec.groupfive.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PostServiceImpl implements PostService {

    @Autowired
    private PostMapper postMapper;

    @Override
    public List<Post> getAllPostsWithStats() {
        return postMapper.getAllPostsWithStats();
    }

    @Override
    public List<PostComment> getPostCommentsWithUserInfo(long postId, int page, int size) {
        int offset = (page - 1) * size;
        return postMapper.getPostCommentsWithUserInfo(postId, offset, size);
    }

    @Override
    public UserInfo getUserByCommentId(String commentId) {
        return postMapper.getUserByCommentId(commentId);
    }
}
